#ifndef _DTU_MQTT_H_
#define _DTU_MQTT_H_

#define MQTT_CFG_MAX_LEN	(256+1)

typedef struct mqtt_info_s {
	unsigned char mode;
	unsigned char debug;	
	unsigned char tls;
	
	unsigned char clean;	
	unsigned short keepalive;

	unsigned int timeout;
	unsigned int heartbeat;	


	unsigned short  port;	
	char host[MQTT_CFG_MAX_LEN];	

	char clientid[MQTT_CFG_MAX_LEN];
	char username[MQTT_CFG_MAX_LEN];
	char password[MQTT_CFG_MAX_LEN];
	
	char productkey[MQTT_CFG_MAX_LEN];
	char devicename[MQTT_CFG_MAX_LEN];
	char devicesecret[MQTT_CFG_MAX_LEN];

	char productsecret[MQTT_CFG_MAX_LEN];

	unsigned char register_mode;		// 设置阿里云连接模式 ；0, 一机一密； 1：一型一密（预注册） ； 2：一型一密（免注册）
	
	char dynregmq_devicesecret[MQTT_CFG_MAX_LEN];

	char dynregmq_clientid[MQTT_CFG_MAX_LEN];
	char dynregmq_username[MQTT_CFG_MAX_LEN];
	char dynregmq_password[MQTT_CFG_MAX_LEN];

	char sub_topic[MQTT_CFG_MAX_LEN];
	unsigned char sub_qos;	

	char pub_topic[MQTT_CFG_MAX_LEN];
	unsigned char pub_qos;
	unsigned char pub_retained;
	
	unsigned char lwt_qos;	
	unsigned char lwt_retained;
	char lwt_topic[MQTT_CFG_MAX_LEN];
	char lwt_payload[MQTT_CFG_MAX_LEN*2];

} mqtt_info_t;


void mqttcfg_init(void);

mqtt_info_t * mqttcfg_get(void);

void mqttcfg_update_nvm(void);

void mqttcfg_remove(void);

#endif
